#ifndef DATA_DEF_H

#define DATA_DEF_H


typedef union
{
	unsigned char Byte;

	struct
	{
		unsigned char		bit0	: 1;
		unsigned char		bit1	: 1;
		unsigned char		bit2	: 1;
		unsigned char		bit3	: 1;
		unsigned char		bit4	: 1;
		unsigned char		bit5	: 1;
		unsigned char		bit6	: 1;
		unsigned char		bit7	: 1;	
	} Bits

} port;


typedef union
{
	unsigned short			Word;
	struct
	{
		unsigned char		ByteLo;
		unsigned char		ByteHi;
	} Bytes;

	struct
	{
		unsigned char		bit0	: 1;
		unsigned char		bit1	: 1;
		unsigned char		bit2	: 1;
		unsigned char		bit3	: 1;
		unsigned char		bit4	: 1;
		unsigned char		bit5	: 1;
		unsigned char		bit6	: 1;
		unsigned char		bit7	: 1;
		unsigned char		bit8	: 1;
		unsigned char		bit9	: 1;
		unsigned char		bit10	: 1;
		unsigned char		bit11	: 1;
		unsigned char		bit12	: 1;
		unsigned char		bit13	: 1;
		unsigned char		bit14	: 1;
		unsigned char		bit15	: 1;
	} Bits;
} sWord;



typedef struct
{
	unsigned char   			slaveAddress;
	unsigned char   			op;
} mbHeader;

typedef union
{

	struct
	{
		sWord startWord;
		sWord numWord;
		sWord CRC;

	} readPacketRequest;

	struct
	{
		unsigned char byteNum;
		sWord * data;
		sWord CRC;
	} readPacketResponse;

	struct
	{
		sWord startWord;
		sWord numWord;
		unsigned char byteNum;
		sWord * data;
		sWord CRC;
	} writePacketRequest;

	struct
	{
		sWord startWord;
		sWord numWord;
		sWord CRC;
	} writePacketResponse;

} mbTail;

typedef struct
{
	mbHeader header;
	mbTail tail;
} mbPacket;


#endif
